import os
import pandas as pd

# 测试矩阵数据
data = {
    "用例编号": ["TC001", "TC002", "TC003", "TC004"],
    "测试类型": ["正向", "反向", "反向", "反向"],
    "产品索引": [2, 2, 2, 2],
    "批号": ["001", "002", "002", "003"],
    "销售日期": ["2025/06/03", "2025/06/04", "2025/06/04", "2025/06/05"],
    "保质期": ["2025/06/30", "20250701", "2025/07/01", "2025.07.08"],
    "测试说明": [
        "正常数据",
        "销售日期格式不规范",
        "序列号重复",
        "保质期格式不规范"
    ],
    "预期结果": [
        "创建成功",
        "创建失败，提示日期格式错误",
        "创建失败，提示批号已存在",
        "创建失败，提示日期格式错误"
    ]
}

# 创建 DataFrame
df = pd.DataFrame(data)

# 创建文件夹
folder = "D:\\pycharm\\PM_test\\Excel"
if not os.path.exists(folder):
    os.makedirs(folder)

# 写入 Excel
file_path = os.path.join(folder, "batch_number_test_matrix.xlsx")
df.to_excel(file_path, index=False, sheet_name="批号测试矩阵")

print(f"批号测试矩阵已保存到：{file_path}")
